home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-28 | 1.8 KB | 87 lines | [TEXT/CWIE] |
- // ExtensibleMenuSection.cp
-
- #ifndef ExtensibleMenuSection_h
- #include "ExtensibleMenuSection.h"
- #endif
-
- ExtensibleMenuSection::ExtensibleMenuSection( Menu& menu )
- : MenuSection( menu, extensible )
- {
- }
-
- uint16 ExtensibleMenuSection::Length() const
- {
- Assert( menu.Length() >= FirstItem() )
- return menu.Length() - FirstItem();
- }
-
- MenuItem ExtensibleMenuSection::operator[]( uint16 index )
- {
- return menu[ firstItem + index ];
- }
-
- void ExtensibleMenuSection::EnableTail( uint32 begin )
- {
- uint32 length = Length();
- Assert( begin <= length );
-
- for ( ; begin < length; begin++ )
- {
- MenuItem item( (*this)[begin] );
- if ( item.CanEnableIndividually() )
- item.Enable();
- else
- {
- menu.EnableTail();
- return;
- }
- }
- }
-
- void ExtensibleMenuSection::DisableTail( uint32 begin )
- {
- uint32 length = Length();
- Assert( begin <= length );
-
- for ( ; begin < length; begin++ )
- {
- MenuItem item( (*this)[begin] );
- if ( item.CanEnableIndividually() )
- item.Disable();
- else
- {
- menu.DisableTail();
- return;
- }
- }
- }
-
- void ExtensibleMenuSection::InsertItem( uint16 index, ConstPString text )
- {
- Assert( CanAdd( FirstItem(), index ) );
- menu.InsertItem( FirstItem() + index, text );
- }
-
- void ExtensibleMenuSection::InsertDivider( uint16 index )
- {
- Assert( CanAdd( FirstItem(), index ) );
- menu.InsertDivider( FirstItem() + index );
- }
-
- void ExtensibleMenuSection::InsertResources( uint16 index, ResType type )
- {
- Assert( CanAdd( FirstItem(), index ) );
- menu.InsertResources( FirstItem() + index, type );
- }
-
- void ExtensibleMenuSection::DeleteItem( uint16 index )
- {
- Assert( CanAdd( FirstItem(), index ) );
- menu.DeleteItem( FirstItem() + index );
- }
-
- void ExtensibleMenuSection::DeleteAll()
- {
- menu.DeleteItems( URange16( FirstItem(), menu.Length() ) );
- }
-